package com.exmple.service.impl;

import com.exmple.dao.IAddressDao;
import com.exmple.model.Address;
import com.exmple.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component
@Scope(value="singleton")
public class AddressServiceImpl2 implements IAddressService {
    @Resource(name = "addressDaoImpl2")
    private IAddressDao addressDaoImpl1;
    AddressServiceImpl2(){
        System.out.println("被创建了");
    }
    @Override
    public int insertAddress() {
        int id=2;
        Address address=new Address();
        address.setId(id);
        address.setAddr("石家庄");
        return  addressDaoImpl1.insertAddress(address);
    }
    @PostConstruct
    public void init(){
        System.out.println("init执行");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("destroy执行");

    }
}
